package org.zgy.stock.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.zgy.stock.model.StockPrice;

import java.time.LocalDate;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class StockPriceDto {
    /**
     * 股票编码
     */
    private String stockCode;
    /**
     * 名称
     */
    private String stockName;
    private LocalDate stockDate;
    private Double openPrice;
    private Double closePrice;
    private Double maxPrice;
    private Double minPrice;
    private Integer volume;
    private Double cje;
    // 涨跌幅
    private Double zdf;
    // 振幅
    private Double zf;
    // 换手率
    private Double hsl;

    public static StockPrice convert(StockPriceDto dto) {
        StockPrice stockPrice = new StockPrice();
        stockPrice.setStockCode(dto.getStockCode());
        stockPrice.setStockName(dto.getStockName());
        stockPrice.setStockDate(dto.getStockDate());
        stockPrice.setOpenPrice(dto.getOpenPrice());
        stockPrice.setClosePrice(dto.getClosePrice());
        stockPrice.setMaxPrice(dto.getMaxPrice());
        stockPrice.setMinPrice(dto.getMinPrice());
        stockPrice.setVolume(dto.getVolume());
        stockPrice.setCje(dto.getCje());
        stockPrice.setZdf(dto.getZdf());
        stockPrice.setZf(dto.getZf());
        stockPrice.setHsl(dto.getHsl());
        return stockPrice;
    }
}
